home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-04-16 | 4.5 KB | 160 lines | [TEXT/CWIE] |
- //----------------------------------------------------------------
- // Abstractor
- // Copyright: © 1997 - 1998 by Apple Computer, Inc., all rights reserved.
- //----------------------------------------------------------------
-
- #pragma once
- #ifndef Abstractor_h
- #define Abstractor_h
-
- #pragma import on
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=power
- #endif
-
- #include "IAExtentCorpus.h"
- #include "VectorAccessor.h"
- #include <time.h>
-
- #pragma IA_BEGIN_EXPORTS
-
- class LetterTree;
-
- const uint32 MAXSENTENCES =1000;
-
- class IAExtentParser : public IAObject
- {
- public:
- IAExtentParser();
- IAExtentParser(byte* buffer, uint32 bufferLength, bool removezReturns = true);
-
- virtual ~IAExtentParser();
-
- void SetBuffer(byte* buffer, uint32 bufferLength);
-
- byte* GetBuffer() const {return fBuffer;}
- uint32 GetBufferLength() const {return fBufferLength;}
-
- void SetStartOfExtent(byte* start) {fStartOfSent = start;}
- byte* GetStartOfExtent() const {return fStartOfSent;}
-
- void SetExtentLength(uint32 length) {fSentLength = length;}
- uint32 GetExtentLength() const {return fSentLength;}
-
- void SetStartOfNext(byte* start) {fStartOfNext = start;}
- byte* GetStartOfNext() const {return fStartOfNext;}
-
- void SetBytesLeft(uint32 length) { fCurrentLength = length;}
- uint32 GetBytesLeft() const {return fCurrentLength;}
-
- void SetGroupNumber(uint32 gNum) {fParagraphNumber = gNum;}
- uint32 GetGroupNumber() const {return fParagraphNumber;}
-
- void SetOrderNumber(uint32 oNum) {fOrderOfSent = oNum;}
- uint32 GetOrderNumber() const {return fOrderOfSent;}
-
- bool IsCancelled() const {return fDidCancel;}
-
- bool AreReturnsRemoved() const {return fRemoveReturns;}
-
- virtual IAExtentDoc* GetNextExtent(RankedProgressFn* progfn, clock_t progFrequency, void* callerData);
-
- protected:
- virtual IAExtentDoc* GettingNextExtent (RankedProgressFn* progfn, clock_t progFrequency, void* callerData, bool *endBuffer) = 0;
-
- private:
-
- byte* fStartOfNext; // start of next parse of activity
- byte* fStartOfSent; // begining of the extent
- uint32 fSentLength; // extent length
-
-
- byte* fBuffer; // text buffer
- uint32 fBufferLength; // length of text buffer
- uint32 fCurrentLength; // bytes left to parse
-
- uint32 fParagraphNumber; // section number
- uint32 fOrderOfSent; // order within a section
-
- bool fDidCancel; // operation was cancelled
- bool fRemoveReturns; // remove returns;
- bool fRanOut; // no need to call again
-
- };
-
-
-
- class IADocumentAbstractor : public IAObject
- {
- public:
- IADocumentAbstractor();
- IADocumentAbstractor(IAExtentParser* parser, IAStorage* storage, IAAnalysis* analysis);
-
- virtual ~IADocumentAbstractor();
-
- virtual void Summarize (RankedProgressFn* progfn, clock_t progFrequency, void* callerData,
- uint32 maxLevel = 0, // how many sentencs will you ask for?
- TermIndex* contextIndex = NULL); // may be NULL for no context index
-
- void SetAnalysis (IAAnalysis* analysis);
- void SetStorage (IAStorage* storage);
- void SetParser(IAExtentParser* parser);
-
- uint32 GetNumberOfExtents () const;
- IAExtentDoc** GetExtents() const;
-
- private:
-
- void FindAbstracts (VectorIndex* index,
- RankedProgressFn* progfn, clock_t progFrequency, void *callerData,
- int maxLevel, TermIndex* contextIndex);
-
- uint32 fNumberSentences;
- IAStorage* fStorage;
- IAAnalysis* fAnalysis;
- IAExtentParser* fParser;
- IAExtentDoc** fSentences;
- RankedHit** fHits;
-
- };
-
-
- class IAANSISentenceParser : public IAExtentParser
- {
- public:
- IAANSISentenceParser(byte* buffer, uint32 bufferLength, const char* abbrevFile = NULL, bool removezReturns = true);
-
- virtual ~IAANSISentenceParser();
-
- // assume sentences to start with upper case letters.
- // false allows sentences to start with lower case
- // default is true
- void SetRequiredUpper(bool value);
- bool IsRequiredUpper() const;
-
- protected:
- virtual IAExtentDoc* GettingNextExtent (RankedProgressFn* progfn, clock_t progFrequency, void* callerData, bool *endBuffer);
-
- private:
- IAANSISentenceParser();
- bool LookUpAbbrev (char* startOfWord, char* endOfWord) const;
-
- LetterTree* fAbbrevDB;
- bool fRequireUpper; // assume sentences to start with upper case letters.
- // false allows sentences to start with lower case
- // default is true
- };
-
-
- IAExceptionCode OutOfRangeSentenceNumber = 'ABSE';
-
- #pragma IA_END_EXPORTS
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #endif
-
- #pragma import reset
- #endif
-